﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.InsertLocationInsideSeam.CCoIlisInsertLocationInsideSeamCmd
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using System;
using System.Windows.Forms;
using Tecnomatix.Engineering;
using Tecnomatix.Engineering.Ui;


namespace DnProcessSimulateCommands.InsertLocationInsideSeam;

public class CCoIlisInsertLocationInsideSeamCmd : TxButtonCommand
{
  private CApIlisInsertLocationEnabler m_enabler;
  private TxForm _insertLocationInsideSeamForm;

  public CCoIlisInsertLocationInsideSeamCmd()
  {
    this.m_enabler = new CApIlisInsertLocationEnabler();
  }

  public virtual void Execute(object cmdParams)
  {
    try
    {
      if (!this.m_enabler.Enable || this._insertLocationInsideSeamForm != null)
        return;
      this._insertLocationInsideSeamForm = (TxForm) new CCUiInsertLocationDlg(this);
      ((Form) this._insertLocationInsideSeamForm).FormClosed += new FormClosedEventHandler(this._insertLocationInsideSeamForm_FormClosed);
      TxApplication.ApplicationEvents.Exiting += new TxApplication_ExitingEventHandler(this.ApplicationEvents_Exiting);
      ((Control) this._insertLocationInsideSeamForm).Show();
    }
    catch (Exception ex)
    {
      int num = (int) MessageBox.Show($"{StringTable.CMD_FAILURE_MSG} {ex.Message}");
      this._insertLocationInsideSeamForm = (TxForm) null;
    }
  }

  private void _insertLocationInsideSeamForm_FormClosed(object sender, FormClosedEventArgs e)
  {
    this._insertLocationInsideSeamForm = (TxForm) null;
    TxApplication.ApplicationEvents.Exiting -= new TxApplication_ExitingEventHandler(this.ApplicationEvents_Exiting);
  }

  private void ApplicationEvents_Exiting(object sender, TxApplication_ExitingEventArgs args)
  {
    if (this._insertLocationInsideSeamForm == null)
      return;
    ((Form) this._insertLocationInsideSeamForm).Close();
  }

  public virtual string Bitmap => StringTable.CMD_BITMAP;

  public virtual string Category => StringTable.CMD_CATEGORY;

  public virtual ITxCommandEnabler CommandEnabler => (ITxCommandEnabler) this.m_enabler;

  public virtual string Description => StringTable.CMD_DESCRIPTION;

  public virtual string Name => StringTable.CMD_NAME;

  public virtual string Tooltip => StringTable.CMD_TOOLTIP;

  public virtual bool Licensed => TxCommandLicenser.InsertLocationInsideSeamLicense;

  public virtual ITxImage Image
  {
    get => (ITxImage) TxImageManager.GetImageByKey("InsertLocationInsideASeam");
  }
}
